package com.cangzhou.cvoa.common;


/**
 * @Author:Tian kangNing
 * @Date:Created in 11:11 2022/5/1
 * @Description: 返回工具类
 */
public class ResultUtils {

    /**
     * @Description: 成功
     * @param: data
     * @return BaseResponse<T>
     * @author NingOba
     * @date 2022/5/2 8:43
    */
    public static <T> BaseResponse<T> success(T data){

        return new BaseResponse<>(200,data,"ok");
    }

    /**
     * @Description: 失败
     * @param: data
     * @return BaseResponse<T>
     * @author NingOba
     * @date 2022/5/2 8:43
     */
    public static BaseResponse error(ErrorCode errorCode){

        return new BaseResponse(errorCode);
    }

    public static BaseResponse error(ErrorCode errorCode,String message, String description){

        return new BaseResponse(errorCode.getCode(),null,message,description);
    }

    public static BaseResponse error(ErrorCode errorCode, String description){

        return new BaseResponse(errorCode.getCode(),errorCode.getMessage(),description);
    }

    public static BaseResponse error(int errorCode, String message, String description){

        return new BaseResponse(errorCode,null,message,description);
    }
}